package operand;

/**
 * The {@link MyError} class is a {@link Operand} which represents an error.
 */
public class MyError<T> extends Operand<T> {
	
	private final String errorMessage;

	/**
	 * Provides the error message.
	 * @return the error message.
	 */
	public String getErrorMessage() {
		return errorMessage;
	}
	/**
	 * Constructor of {@link MyError}.
	 * No error message is set.
	 */
	public MyError(){
		this("");
	}
	/**
	 * Constructor of {@link MyError}.
	 * @param errorMessage is the error message of this error.
	 */
	public MyError(final String errorMessage){
		this.errorMessage = errorMessage;
	}
	
	@Override
	public Operand<T> accept(final OperandVisitor<T> visitor) {
		return visitor.visit(this);
	}
	@Override
	public void accept(final OperandVisitorWithoutResult<T> visitor) {
		visitor.visit(this);
	}
}
